﻿--必须在每个分账套数据库运行

--保存主帐套与分账套关键字的对应关系

--TableName:表名。如果关键字是fitemid,既要写t_item表的，值一律是t_item。其它则是对应实际表名
--OrgKeyValue：主帐套关键字的值
--DestKeyValue：分账套关键字的值
CREATE TABLE dbo.mKeyMap
	(
	RecID int NOT NULL IDENTITY (1, 1),
	TableName varchar(50) NOT NULL,
	OrgKeyValue varchar(50) NOT NULL,
	DestKeyValue varchar(50) NULL
	)  ON [PRIMARY]
GO
ALTER TABLE dbo.mKeyMap ADD CONSTRAINT
	PK_mKeyMap PRIMARY KEY CLUSTERED 
	(
	TableName,
	OrgKeyValue
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

GO